package com.example.administrator.foodrowfresh.configs.classifyconfing.classifyadapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.administrator.foodrowfresh.R;
import com.example.administrator.foodrowfresh.configs.classifyconfing.classifyentity.MyClassifyDetailEntity;
import com.example.administrator.foodrowfresh.superBase.MyBaseAdapter;

import org.xutils.x;

import java.util.List;

/**
 * Created by lqr on 2016/5/3.
 */
public class MyClassifyDetailAdapter extends MyBaseAdapter<MyClassifyDetailEntity.DataBean.ListBean> {
    private List<MyClassifyDetailEntity.DataBean.ListBean> list;
    private Context mContext;
    public MyClassifyDetailAdapter(List<MyClassifyDetailEntity.DataBean.ListBean> list, Context mContext) {
        super(list, mContext);
        this.list=list;
        this.mContext=mContext;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if(convertView==null){
            convertView= LayoutInflater.from(mContext).inflate(R.layout.layout_detail_item,parent,false);
            holder=new ViewHolder(convertView);
            convertView.setTag(holder);
        }else {
            holder= (ViewHolder) convertView.getTag();
        }
        holder.detail_name.setText(list.get(position).getName());
        holder.detail_price.setText("¥"+list.get(position).getUnitprice()+"");
        holder.detail_weight.setText(list.get(position).getPrice()+"/"+list.get(position).getPvweight());
        holder.detail_id.setText(list.get(position).getId()+"");
        String imagePath=list.get(position).getImage();
        x.image().bind(holder.detail_image,imagePath);
        return convertView;
    }

    public class ViewHolder{
        TextView detail_name;
        TextView detail_price;
        TextView detail_weight;
        TextView detail_id;
        ImageView detail_image;
        public ViewHolder(View view) {
            detail_name= (TextView) view.findViewById(R.id.detail_name);
            detail_price= (TextView) view.findViewById(R.id.detail_price);
            detail_weight= (TextView) view.findViewById(R.id.detail_weight);
            detail_image= (ImageView) view.findViewById(R.id.detail_image);
            detail_id= (TextView) view.findViewById(R.id.detail_id);
        }

    }
}
